package com.a

import java.lang

import org.apache.spark.sql.functions.desc
import org.apache.spark.sql.{DataFrame, Dataset, SparkSession}

/**
 * @author Liu Guibin
 * @date 2020/9/1 10:39
 */
object scalaTest {
  //Logger.getLogger("org").setLevel(Level.FATAL)
  def main(args: Array[String]): Unit = {
    val session: SparkSession = SparkSession.builder()
      .appName("test")
      .master("local")
      .getOrCreate()
    val dataSet: Dataset[lang.Long] = session.range(1, 1000, 5, 4)
    val data: Dataset[lang.Long] = dataSet.orderBy(desc("id"))
    data.show(100, false)

    val dataFrame: DataFrame = session.createDataFrame(List(("小明", 121), ("小红", 34)))
    val frame: DataFrame = dataFrame.withColumnRenamed("_1", "name")
      .withColumnRenamed("_2", "age")
    //frame.orderBy(desc("age")).show()
  }
}
